package com.zhala.web.controller.system;

import com.zhala.common.annotation.Log;
import com.zhala.common.core.controller.BaseController;
import com.zhala.common.core.domain.AjaxResult;
import com.zhala.common.core.domain.CommonResult;
import com.zhala.common.core.page.TableDataInfo;
import com.zhala.common.enums.BusinessType;
import com.zhala.common.utils.poi.ExcelUtil;
import com.zhala.system.domain.ZlSteelBigPipe;
import com.zhala.system.domain.vo.*;
import com.zhala.system.service.IZlSteelBigPipeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * 大管相关API
 * 
 * @author ruoyi
 * @date 2024-11-11
 */
@Api("数据大屏")
@RestController
@RequestMapping("/app/big-pipe")
public class AppSteelBigPipeController extends BaseController {
    @Autowired
    private IZlSteelBigPipeService zlSteelBigPipeService;

    /**
     * 工序退回
     */
    @Log(title = "工序退回", businessType = BusinessType.INSERT)
    @ApiOperation("工序退回")
    @PostMapping("/roll-back")
    public CommonResult<Boolean> rollBack(@RequestBody @Valid PipeRollBackReqVO reqVO) {
        return zlSteelBigPipeService.rollBack(reqVO);
    }

    /**
     * 工序6-管节大组
     */
    @Log(title = "管节大组", businessType = BusinessType.INSERT)
    @PostMapping("/settings")
    public CommonResult<Boolean> settings(@RequestBody @Valid SteelBigPipeReqVO reqVO) {
        return zlSteelBigPipeService.settings(reqVO);
    }

    /**
     * 工序6-管节大组-修改
     */
    @Log(title = "工序6管节大组-修改", businessType = BusinessType.INSERT)
    @PostMapping("/settings-update")
    public CommonResult<Boolean> settingsUpdate(@RequestBody @Valid SteelBigPipeReqVO reqVO) {
        return zlSteelBigPipeService.settingsUpdate(reqVO);
    }

    /**
     * 工序7-环缝焊接
     */
    @Log(title = "工序7-环缝焊接", businessType = BusinessType.INSERT)
    @PostMapping("/girth-weld")
    public CommonResult<Boolean> girthWeld(@RequestBody @Valid SteelBigPipeGirtWeldReqVO reqVO) {
        return zlSteelBigPipeService.girthWeld(reqVO,Boolean.FALSE);
    }

    /**
     * 工序7-环缝焊接-修改
     */
    @Log(title = "工序7-环缝焊接-修改", businessType = BusinessType.INSERT)
    @PostMapping("/girth-weld-update")
    public CommonResult<Boolean> girthWeldUpdate(@RequestBody @Valid SteelBigPipeGirtWeldReqVO reqVO) {
        return zlSteelBigPipeService.girthWeld(reqVO,Boolean.TRUE);
    }


    /**
     * 工序8-管节调圆
     */
    @Log(title = "工序8-管节调圆", businessType = BusinessType.INSERT)
    @PostMapping("/pipe-circular")
    public CommonResult<Boolean> pipeCircular(@RequestBody @Valid BigPipeCircularReqVO reqVO) {
        return zlSteelBigPipeService.pipeCircular(reqVO);
    }

    /**
     * 工序9-加劲环安装
     */
    @Log(title = "工序9-加劲环安装", businessType = BusinessType.INSERT)
    @PostMapping("/stiffen-ring")
    public CommonResult<Boolean> stiffenRing(@RequestBody @Valid BigPipeStiffenRingReqVO reqVO) {
        return zlSteelBigPipeService.stiffenRing(reqVO);
    }

    /**
     * 工序10-加劲环焊接工序
     */
    @Log(title = "工序10-加劲环焊接工序", businessType = BusinessType.INSERT)
    @PostMapping("/stiffen-ring-weld")
    public CommonResult<Boolean> stiffenRingWeld(@RequestBody @Valid BigPipeStiffenRingWeldReqVO reqVO) {
        return zlSteelBigPipeService.stiffenRingWeld(reqVO);
    }


    /**
     * 工序11-验收工序
     */
    @Log(title = "工序11-验收工序", businessType = BusinessType.INSERT)
    @PostMapping("/acceptance")
    public CommonResult<Boolean> acceptance(@RequestBody @Valid BigPipeAcceptanceReqVO reqVO) {
        return zlSteelBigPipeService.acceptance(reqVO);
    }

    /**
     * 工序12-管节防腐
     */
    @Log(title = "工序12-管节防腐", businessType = BusinessType.INSERT)
    @PostMapping("/antisepsis")
    public CommonResult<Boolean> antisepsis(@RequestBody @Valid BigPipeAntisepsisReqVO reqVO) {
        return zlSteelBigPipeService.antisepsis(reqVO,Boolean.FALSE);
    }

    /**
     * 工序12-管节防腐-修改
     */
    @Log(title = "工序12-管节防腐-修改", businessType = BusinessType.INSERT)
    @PostMapping("/antisepsis-update")
    public CommonResult<Boolean> antisepsisUpdate(@RequestBody @Valid BigPipeAntisepsisReqVO reqVO) {
        return zlSteelBigPipeService.antisepsis(reqVO,Boolean.TRUE);
    }

    /**
     * 报废
     */
    @Log(title = "报废", businessType = BusinessType.INSERT)
    @PostMapping("/scrap")
    public CommonResult<Boolean> scrap(@RequestBody @Valid PipeScrapReqVO reqVO) {
        return zlSteelBigPipeService.scrap(reqVO);
    }

    /**
     * 大管详情
     */
    @GetMapping("/info")
    @Parameter(name = "id", description = "大管ID", required = false)
    @Parameter(name = "type", description = "0:获取基础详情 1:带时间线详情", required = false)
    public CommonResult<SteelBigPipeRespVO> info(@RequestParam("id")String id, @RequestParam("type")Integer type) {
        return zlSteelBigPipeService.info(id,type);
    }
}
